//
//  DENFavorableTAbleViewCell.m
//  Icar
//
//  Created by apple on 15/10/16.
//  Copyright © 2015年 小龙侠. All rights reserved.
//

#import "DENFavorableTAbleViewCell.h"
#import "BaseHeader.h"
@implementation DENFavorableTAbleViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creat];
    }
    return self;
}
- (void)creat
{
    self.modelNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 10,ADJUSTHEIGHT * 20, ADJUSTWIDTH * 320, ADJUSTHEIGHT * 30)];
    self.modelNameLabel.font =[UIFont systemFontOfSize:18. * ADJUSTWIDTH];
    self.modelNameLabel.numberOfLines = 0;
    [self.contentView addSubview:self.modelNameLabel];
    
    self.dealerNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 10, ADJUSTHEIGHT*40, ADJUSTWIDTH * 240, ADJUSTHEIGHT * 50)];
    self.dealerNameLabel.font =[UIFont systemFontOfSize:14. * ADJUSTWIDTH];
    [self.dealerNameLabel setTextColor:[UIColor grayColor]];
    self.dealerNameLabel.numberOfLines = 0;
    [self.contentView addSubview:self.dealerNameLabel];
    
    self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 280, ADJUSTHEIGHT * 60, ADJUSTWIDTH * 80, ADJUSTHEIGHT * 25)];
    self.priceLabel.font =[UIFont systemFontOfSize:15. * ADJUSTWIDTH];
    self.priceLabel.textColor = [UIColor redColor];
    self.priceLabel.numberOfLines = 0;
    [self.contentView addSubview:self.priceLabel];
    
    self.modelDownLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 280, ADJUSTHEIGHT * 85, ADJUSTHEIGHT * 80, ADJUSTHEIGHT * 30)];
    self.modelDownLabel.font =[UIFont systemFontOfSize:14.* ADJUSTWIDTH];
    self.modelDownLabel.textColor = [UIColor greenColor];
    self.modelDownLabel.numberOfLines = 0;
    [self.contentView addSubview:self.modelDownLabel];
    
    self.namelistRangeLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 10, ADJUSTHEIGHT * 75, ADJUSTHEIGHT * 60, ADJUSTHEIGHT * 30)];
    self.namelistRangeLabel.font =[UIFont systemFontOfSize:14.* ADJUSTWIDTH];
    self.namelistRangeLabel.numberOfLines = 0;
    self.namelistRangeLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.namelistRangeLabel];
    
    self.modelType = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 75, ADJUSTHEIGHT * 75, ADJUSTHEIGHT * 75, ADJUSTHEIGHT * 30)];
    self.modelType.font =[UIFont systemFontOfSize:14.* ADJUSTWIDTH];
    self.modelType.numberOfLines = 0;
    self.modelType.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.modelType];
    
    _label = [[UILabel alloc]initWithFrame:CGRectMake(0, 110 * ADJUSTHEIGHT, SCREEN_WIDTH, ADJUSTHEIGHT * 49)];
    [self.contentView addSubview:_label];
    
    self.phoneButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.phoneButton setFrame:CGRectMake(0, 113 * ADJUSTHEIGHT, SCREEN_WIDTH / 2 -  1, 35 * ADJUSTHEIGHT)];
    [self.phoneButton setTitle:@" 电话资讯" forState:UIControlStateNormal];
    [self.phoneButton setImage:[UIImage imageNamed:@"54.png"] forState:UIControlStateNormal];
    [self.phoneButton setTitleColor:[UIColor colorWithRed:0.09 green:0.67 blue:0.24 alpha:1] forState:UIControlStateNormal];
    [self.contentView addSubview:self.phoneButton];
    
    self.privilegeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.privilegeButton setFrame:CGRectMake(SCREEN_WIDTH / 2 + 1,113 * ADJUSTHEIGHT , SCREEN_WIDTH / 2 - 1, 35 * ADJUSTHEIGHT)];
    [self.privilegeButton setTitle:@" 我要优惠" forState:UIControlStateNormal];
    [self.privilegeButton setTitleColor:[UIColor colorWithRed:0 green:0.47 blue:0.89 alpha:1] forState:UIControlStateNormal];
    [self.privilegeButton setImage:[UIImage imageNamed:@"55.png"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.privilegeButton];
    
}
- (void)getDenMessage:(DENFavorableModel *)modelFav
{
    self.modelNameLabel.text = modelFav.modelName;
    self.dealerNameLabel.text = modelFav.dealerName;
    [self.priceLabel setText:[NSString stringWithFormat:@"￥%@万",modelFav.price]];
    CGFloat time = [modelFav.discount intValue];
    [self.modelDownLabel setText:[NSString stringWithFormat:@"↓%.2f万",time / 10000]];
    if ([[modelFav.namelistRange description] isEqualToString:@"1"]) {
        self.namelistRangeLabel.text = @"售本省";
    }
    else
    {
        self.namelistRangeLabel.text = @"售本市";
    }
    if ([modelFav.modelType isEqualToString:@"1"]) {
        self.modelType.text = @"现车充足";
    }
    else
    {
        self.modelType.text = @"少量现车";
    }
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
